package testpro01;

import java.util.Scanner;

/**
 * Created by Miracle yaochengwei on 2022/7/9 21:31
 */
public class ArryTest {
    public static void main(String[] args) {
        MyTools mt = new MyTools();
        int[] arr = {10, -1, 8, 0, 34};
        mt.bubble(arr);
        //输出排序后的arr，引用传
        System.out.println("==输出排序后的arr==");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i] + "\t");
        }
        Scanner myScanner = new Scanner(System.in);
        Scanner scanner = new Scanner(System.in);
        Scanner scanner1 = new Scanner(System.in);
        Scanner scanner2 = new Scanner(System.in);
//开始快捷键自动分配变量名

        //老韩一个解惑
//在idea 当我们run 一个文件时，会先编译再cLass ->在运行
    }
}

//查看类的继承关系 ctrl +h
class Person {
    String name;
    int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    //构造器快捷键  alt +insert
}
//创建一个类MyTooLs,编写一个方法，可以完成对int数组冒泡排序的功能
//要求从小到大


class MyTools {
    public void bubble(int[] arr) {
        //冒泡排序
        int temp = 0;
        for (int i = 0; i < arr.length - 1; i++) {//外层循环次数arr.Length - 1
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {//交换
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;

                }

            }
        }
    }
}

